package cn.com.thinvent.dispatch.web.controller;

import cn.com.thinvent.dispatch.entity.IndicatorList;
import cn.com.thinvent.dispatch.entity.response.PagedGridResult;
import cn.com.thinvent.dispatch.entity.response.ReturnModel;
import cn.com.thinvent.dispatch.service.biz.IndicatorListService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @projectName: pdfToText
 * @package: cn.com.thinvent.dispatch.web.controller
 * @className: IndicatorListController
 * @author: wjz

 * @date: 2024/4/10 15:59
 * @version: 1.0
 **/

@Api(description = "IndicatorList模块")
@Controller
@RequestMapping("/indicatorList")
@CrossOrigin(origins = "*")
@ResponseBody
public class IndicatorListController {
    @Autowired
    private IndicatorListService indicatorListService;
    /**
     * 指标列表
     * @param name
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/list")
    @ResponseBody
    public ReturnModel list(@RequestParam("name") String name,
                            @RequestParam("pageNum") Integer pageNum,
                            @RequestParam("pageSize") Integer pageSize) {
        PagedGridResult<IndicatorList> list = indicatorListService.list(name, pageNum, pageSize);
        return new ReturnModel(200, list, "");
    }
    /**
     * 新增指标
     * @param indicatorList
     * @return
     */
    @PostMapping("/saveOrUpdate")
    @ResponseBody
    public ReturnModel saveOrUpdate(@RequestBody IndicatorList indicatorList) {
        IndicatorList target = indicatorListService.saveOrUpdate(indicatorList);
        return new ReturnModel(200, target, "");
    }

    /**
     * 删除指标
     * @param id
     * @return
     */
    @GetMapping("/delete")
    @ResponseBody
    public ReturnModel delete(@RequestParam("id") Integer id) {
        Integer delete = indicatorListService.deleteById(id);
        return new ReturnModel(200, delete, "删除成功");
    }
    /**
     * 删除指标
     * @param id
     * @return
     */
    @GetMapping("/indicators")
    @ResponseBody
    public ReturnModel getIndicators(@RequestParam("id") Integer id) {
        String  result = indicatorListService.getIndicators(id);
        return new ReturnModel(200, result, "查询成功");
    }

}

